#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

class Solution {
   public:
    string orderlyQueue(string s, int k) {
        if (k == 1) {
            string small = s;
            int n = s.size();
            for (int i = 1; i < n; i++) {
                char c = s[0];
                s = s.substr(1);
                s.push_back(c);
                if (s < small) {
                    small = s;
                }
            }
            return small;
        } else {
            sort(s.begin(), s.end());
            return s;
        }
    }
};
int main() {
    Solution s;
    // cout << s.orderlyQueue("baaca", 3);
    // cout << (bool)s.isStringUp("cba") << endl;
    cout << s.orderlyQueue("cba", 1);
    return 0;
}
